package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CheckGroupDao {

    //@Insert("insert into t_checkgroup values(null,#{code},#{name},#{helpCode},#{sex},#{remark},#{attention})")
    public void addGroup(CheckGroup checkGroup);

    @Insert("insert into t_checkgroup_checkitem  values(#{checkgroup_id},#{checkitem_id})")
    void addGroupAndItem(@Param("checkgroup_id") Integer gid,@Param("checkitem_id") Integer id);

    Page selectAllByName(String name);

    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id}")
    Integer[] findById(int id);

    public void update(CheckGroup checkGroup);

    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{id}")
    public void deleteById(int id);

    @Select("select count(*) from t_setmeal_checkgroup where checkgroup_id = #{id}")
    public int findCountById(int id);

    @Delete("delete from t_checkgroup where id=#{id}")
    void deleteByGId(int id);

    @Select("select count(*) from t_checkgroup_checkitem where checkgroup_id = #{id}")
    int selectCountById(int id);

    @Select("select * from t_checkgroup")
    List<CheckGroup> findAll();
}
